package com.zlq.cn.task;

import com.zlq.cn.service.un.LocationLogService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 每10秒同步一次定位数据
 */
@Component
// 该配置可以实现测试环境不开启定时器
@ConditionalOnProperty(prefix = "finder-config", name = "open-task", havingValue = "true")
public class LocationLogSchedulerTask {
    @Resource
    private LocationLogService locationLogService;

    // 每10秒触发一次
    @Scheduled(cron = "0/10 * * * * ? ")
    public void task() {
        try {
            locationLogService.saveLocationLog();
        } catch (Exception ignored) {

        }
    }

}
